package com.yidu.web.utils;

import com.google.gson.Gson;

import javax.servlet.http.HttpServletResponse;
import javax.websocket.Session;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class SessionTools {

    /**
     * 用户在线状态
     */
    public static final String STATUS_ON = "1";
    public static final String STATUS_OFF = "0";


    //专门放session的集合
    public static Map<String,Object> SESSIONS = new ConcurrentHashMap<>();


    public static void writerJson(HttpServletResponse response,Object object) throws IOException {
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        Gson gson = new Gson();
        String json = gson.toJson(object);
        out.print(json);
        out.close();
    }
}
